package com.hbx.platform.base.config;

import com.hbx.platform.base.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: hbx
 * @date: 2024/04/08
 **/
@Configuration //也可以在启动类上实现WebMvcConfigurer来注册拦截器
public class MyMvcInterceptor implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")//黑名单
                .excludePathPatterns("/auth/login","/auth/logout");//白名单
    }
}
